<template>
    <rx-dialog @handOk="handOk" @cancel="cancel">
        <rx-layout class="FormTransConfigDialog">
            <div slot="header" border="false" style="height: 50px">
                <a-form>
                    <a-row :gutter="24">
                        <a-col :span="12">
                            <a-form-item :label="$ti18('rxForm.name','名称')">
                                <a-input style="width: 100%" :placeholder="$ti18('rxForm.name','名称','','input')" v-model="queryParam.Q_NAME__S_LK"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                                  <span class="table-page-search-submitButtons">
                                    <a-button type="primary" @click="$refs.table.loadData()" icon="search">{{$ti18('rxList.searchBtn','查询')}}</a-button>
                                    <a-button style="margin-left: 4px" @click="resetSearch2">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                                  </span>
                        </a-col>
                    </a-row>
                </a-form>
            </div>
            <div slot="center" style="margin-top: 10px">
                <rx-grid
                    style="width: calc(100% - 1px);"
                    ref="table"
                    :bordered="false"
                    :allowRowSelect="true"
                    :multiSelect="multiSelect"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formTransConfig/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="id"
                    type="radio"
                    @selectChange="onSelectChange"
                    selectedRowKeys="selectedRowKeys"
                >
                    <span slot="status" slot-scope="{ text, record }">
                        {{text==1?$comi18('rxDialog.statusYse', '启用'):$comi18('rxDialog.statusNo', '禁用')}}
                    </span>
                </rx-grid>
            </div>
        </rx-layout>
    </rx-dialog>
</template>

<script>

import {BaseList, RxLayout, Util} from "@lowcode/jpaas-common-lib"

export default {
    name: 'FormTransConfigDialog',
    mixins: [BaseList],
    components: {
        RxLayout
    },
    props: {
        layerid: {
            type: String,
            default: ""
        },
        destroy: {
            type: Function
        },
        /**
         * 业务模型ID
         */
        boDefId:{
            type: String,
            default: ""
        },
    },
    data() {
        return {
            columns: [
                {
                    title: this.$ti18('rxList.index','序号'),
                    type: 'indexColumn',
                    width: 50,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: this.i18n('form.name','名称'), dataIndex: 'name', width: 150},
                {title: this.i18n('form.sourceBodefName','源业务模型名称'), dataIndex: 'sourceBodefName', width: 150},
                {title: this.i18n('form.targetSolutionName','目标表单方案名称'), dataIndex: 'targetSolutionName'},
                {title: this.i18n('form.status','状态'), dataIndex: 'status', width: 80,  scopedSlots: {customRender: 'status'}},
                {title: this.i18n('form.transType','转换类型'), dataIndex: 'transType', width: 100},
            ],
        }

    },
    created() {
        this.queryParam["Q_SOURCE_BODEF_ID__S_EQ"] = this.boDefId
        this.queryParam["Q_STATUS__I_EQ"] = 1;
        this.needFilterAppId();
        let appId=this.curApp.appId;
        var queryAppId=this.appId;
        if(queryAppId && queryAppId!=0){
            this.queryParam.Q_APP_ID__S_EQ=queryAppId;
        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"formTransConfig",key);
        },
        cancel() {
            Util.closeWindow(this, "cancel");
        },
        resetSearch2() {
            this.queryParam = {};
            this.$nextTick(() => {
                this.queryParam["Q_SOURCE_BODEF_ID__S_EQ"] = this.boDefId;
                this.queryParam["Q_STATUS__I_EQ"] = 1;
                let appId = this.curApp.appId;
                if (appId) {
                    this.queryParam.Q_APP_ID__S_EQ = appId;
                }
                this.$nextTick(() => {
                    this.$refs[this.table].loadData();
                })
            })
        },
        handOk(vm) {
            var rows = this.selectedRows;
            if (rows.length == 0) {
                vm.loading = false;
                this.$message.warning(this.$ti18('rxMsa.masWarn.selectOneRecord','请选择一行记录!'));
                return;
            }
            Util.closeWindow(this, "ok", this.selectedRows);
        },
    }
}
</script>
<style scoped>
.FormTransConfigDialog>>>.modeleBox{
    border: none!important;
}
</style>

